<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>订单编辑</title>
<link href="<%=basePath%>skin/css/validform/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=basePath%>skin/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/validform/Validform_v5.3.2_min.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/jquery.tools.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/jquery.lSelect.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/common.js"></script>
<script language="javascript">
	 $().ready(function() {
		//验证
		var validform = $("#form1").Validform({
			btnSubmit:"#save",
			tiptype:3,
			datatype:{
				"phone":function(gets,obj,curform,regxp){
					var decimalReg=/^(^(\d{3,4}-)?\d{7,8})$|(13[0-9]{9})$/;
					if(gets == null || gets == ""){
						return "请填写信息";
					}
					if(decimalReg.test(gets)){
						return true;
					}
					return "请填写电话或手机";
				}
			}
		});
		validform.addRule([
			{
			    ele:"#consignee",
			    datatype:"*",
			    nullmsg:"请输入收货人！"
			},
			{
			    ele:"#address",
			    datatype:"*",
			    nullmsg:"请输入地址！"
			},
			{
			    ele:"#zipCode",
			    datatype:"p",
			    nullmsg:"请输入邮编！"
			},
			{
			    ele:"#phone",
			    datatype:"phone",
			    nullmsg:"请输入电话！"
			}
		]);
		// 地区选择
		$("#areaId").lSelect({
			url: "<%=basePath%>area.shtml"
		});
	 });
</script>
</head>

<body>
	<form id="form1" name="form1" method="post" action="<%=basePath%>admin/order/update.shtml">
		<input type="hidden" name="id" value="${order.id}" />
		<ul id="tab" class="tab">
			<li><input type="button" value="订单信息" /></li>
			<li><input type="button" value="商品信息" /></li>
		</ul>
		<table width="98%" class="input tabContent">
			<tr bgcolor="#FAFAF1" height="22">
				<th width="10%" align="right">编号：</th>
				<td width="40%">${order.sn }</td>
				<th width="10%" align="right">创建日期：</th>
				<td width="40%"><fmt:formatDate value="${order.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<th align="right">订单状态：</th>
				<td>${order.orderStatus }</td>
				<th align="right">支付状态：</th>
				<td>${order.paymentStatus }</td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<th align="right">配送状态：</th>
				<td>${order.shippingStatus }</td>
				<th align="right">用户名：</th>
				<td>${order.sn }</td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<th align="right">订单金额：</th>
				<td><fmt:formatNumber value="${order.amount}" pattern="0.00"/></td>
				<th align="right">已付金额：</th>
				<td><fmt:formatNumber value="${order.amountPaid }" pattern="0.00"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<th align="right">商品重量：</th>
				<td><fmt:formatNumber value="${order.weight }" pattern="0.00"/></td>
				<th align="right">商品数量：</th>
				<td><fmt:formatNumber value="${order.quantity }" pattern="0.00"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<th align="right">运费：</th>
				<td><fmt:formatNumber value="${order.freight }" pattern="0.00"/></td>
				<th align="right">支付手续费：</th>
				<td><fmt:formatNumber value="${order.fee }" pattern="0.00"/></td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<th align="right">支付方式：</th>
				<td>${order.paymentMethodName }</td>
				<th align="right">配送方式：</th>
				<td>${order.shippingMethodName }</td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<th align="right">发票抬头：</th>
				<td>
					<input id="invoiceTitle" name="invoiceTitle" size="15" class="input" value="${order.invoiceTitle }"/> 
					<input type="checkbox" id="isInvoice" name="isInvoice" value="true" <c:if test="${order.isInvoice }">checked</c:if> /> 是否开据发票
				</td>
				<th align="right">税金：</th>
				<td>0</td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<th align="right">收货人：</th>
				<td><input id="consignee" name="consignee" size="15" class="input" value="${order.consignee }"/></td>
				<th align="right">地区：</th>
				<td>
					<input type="hidden" id="areaId" name="areaId" value="${order.area.id}" treePath="${order.area.treePath}" />
				 </td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<th align="right">地址：</th>
				<td><input id="address" name="address" size="15" class="input" value="${order.address }"/></td>
				<th align="right">邮编：</th>
				<td>
					<input id="zipCode" name="zipCode" size="15" class="input" value="${order.zipCode }"/>
				 </td>
			</tr>
			<tr bgcolor="#FAFAF1" height="22">
				<th align="right">电话：</th>
				<td><input id="phone" name="phone" size="15" class="input" value="${order.phone }"/></td>
				<th align="right">附言：</th>
				<td colspan=3>
					${order.memo }
				 </td>
			</tr> 
		</table>
		<table width="98%" class="input tabContent">
			<tr align="center" bgcolor="#E7E7E7" height="22">
				<td width="20%">
					编号
				</td>
				<td width="20%">
					名称
				</td>
				<td width="20%">
					价格
				</td>
				<td width="20%">
					数量
				</td>
				<td width="20%">
					小计
				</td>
			</tr>
			<c:forEach items="${order.orderItems}" var="orderItem">
				<tr align='center' bgcolor="#FFFFFF"
						onMouseMove="javascript:this.bgColor='#FCFDEE';"
						onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
			  		<td>${orderItem.sn}</td>
			  		<td>${orderItem.fullName} <c:if test="${orderItem.isGift }"><font color="red">[赠品]</font></c:if></td>
			  		<td>
			  			<c:choose>
			  				<c:when test="${orderItem.isGift }">-</c:when>
			  				<c:otherwise><fmt:formatNumber value="${orderItem.price}" pattern="0.00"/></c:otherwise>
			  			</c:choose>
			  		</td>
			  		<td>
			  			<c:choose>
			  				<c:when test="${orderItem.isGift }">-</c:when>
			  				<c:otherwise><fmt:formatNumber value="${orderItem.quantity}" pattern="0.00"/></c:otherwise>
			  			</c:choose>
			  		</td>
			  		<td>
						<c:choose>
			  				<c:when test="${orderItem.isGift }">-</c:when>
			  				<c:otherwise><fmt:formatNumber value="${orderItem.subtotal}" pattern="0.00"/></c:otherwise>
			  			</c:choose>
					</td>
		  	</c:forEach>
	  	</table>
		<table width="98%">
			<tr bgcolor="#EEF4EA">
				<td height="36" colspan="10">
					<input type="button" value="确定" class="button" id="save"/>
					<input type="button" value="返回" class="button" onclick="location.href='<%=basePath%>admin/order/list.shtml'" />
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
